home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 983 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.0 KB

  1. Path: fido.asd.sgi.com!austern
  2. From: clamage@Eng.Sun.COM (Steve Clamage)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Must exception classes have copy constructors?
  5. Date: 06 Apr 1996 11:35:46 PST
  6. Organization: Sun Microsystems Inc., Mountain View, CA
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <4k6130$l22@engnews1.Eng.Sun.COM>
  9. References: <606373375wnr@ma.ccngroup.com>
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. X-Original-Date: 6 Apr 1996 15:02:56 GMT
  12. X-Newsreader: NN version 6.5.0 #21 (NOV)
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBVAwUBMWbHkky4NqrwXLNJAQHVtgH/Z4+hvCau+oTdn9LTiQYRoqd3a2WaoxpV
  15.     AibiY3q9X4Jg/nP8orD/LBsZ67S9aXx3N2Hh8BeTOZuLiEUpn7AuAw==
  16.     =6uYg
  17. Originator: austern@isolde.mti.sgi.com
  18.  
  19. Alan Griffiths <aGriffiths@ma.ccngroup.com> writes:
  20.  
  21. >I've just tried porting some code to MSVC4 (it compiles and works with 
  22. >SC7.1 and BC4.5).
  23.  
  24. >In effect it appears that the Microsoft compiler _requires_ anything 
  25. >thrown as an exception to have an accessible copy constructor.  (I've 
  26. >tended to make copy constructors private to ensure catch-by-reference
  27. >and aviod slicing bugs.)
  28.  
  29. According to the draft standard, when you throw something, what is
  30. thrown is actually a copy of that something. If the copy constructor
  31. for that something is not accessible, the copy can't be made.
  32.  
  33. Under some circumstances the copy can be optimized away. The draft
  34. standard was recently clarified to say that when logically a copy
  35. is needed, the copy constructor must be accessible even if in a
  36. particular case a compiler happens to optimize away the copy.
  37.  
  38. In your case, you will probably have to throw a pointer instead
  39. of a value, if the type has a private copy constructor.
  40. --
  41. Steve Clamage, stephen.clamage@eng.sun.com
  42. ---
  43. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  44.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  45.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  46.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  47.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  48. ]
  49.